<template>
  <div>
    <msg title="购买成功" description="恭喜你下单成功" :buttons="buttons" :icon="icon"></msg>
  </div>
</template>

<script>
  import {Msg, Divider, XButton} from 'vux';
  import axios from 'axios';

  import {isiOS} from '../../utils/common'
  export default {
    components: {
      Msg,
      Divider,
      XButton
    },
    data () {
      return {
        description: 'msg description',
        icon: '',
        buttons: [{
          type: 'primary',
          text: '继续购买',
          onClick: ()=> {
            this.getjumpurl(this.appcode);
          }
        }]
      }
    },
    created() {
      this.appcode = this.$route.params.appcode;
    },
    methods: {
      async getjumpurl(AppCode){
        const downurl = 'http://cp.lovedou.com';
        const {data}= await axios.get(`/base/Handler.ashx?action=16&params={"AppCode":"${AppCode}"}`);
        if(data && data.code === 0) {
          if(isiOS()) {
            window.location.href = data.data.IOSUrl ? `${data.data.IOSUrl}orderdetail` : downurl;
          }
          else {
            window.location.href = data.data.AndroidUrl ? `${data.data.AndroidUrl}orderdetail` : downurl;
          }
        }
      }
    }

  }
</script>
